package theeg.DependencyAnalysis.Core;

import theeg.DependencyAnalysis.Core.DataModel.DependencyModel;
import theeg.DependencyAnalysis.Core.DataModel.DependencyModelImplementation;
import theeg.DependencyAnalysis.Core.Internal.JreAnalyzer;
import theeg.DependencyAnalysis.Core.Internal.MetricsImplementation;
import theeg.DependencyAnalysis.Core.Internal.VerifierImplementation;
import theeg.DependencyAnalysis.Core.Serialization.Report;

public class Setup
{
    private DependencyModel model;
    private Analyzer analyzer;
    private Verifier verifier;
    private Metrics metrics;

    private Setup()
    {
    }

    /// <summary>
/// Create a test setup with Verification and Metrics.
/// </summary>
/// <returns></returns>
    public static Setup buildStandardSetup()
    {
        DependencyModel dependencyModel = new DependencyModelImplementation();
        Setup setup = new Setup();
        setup.model = dependencyModel;
        setup.analyzer = new JreAnalyzer(dependencyModel);
        setup.verifier = new VerifierImplementation(dependencyModel);
        setup.metrics = new MetricsImplementation(dependencyModel);
        return setup;
    }

    /// <summary>
/// Create a test setup with Verification and Metrics given an existing
/// data model.
/// </summary>
/// <returns></returns>
    public static Setup buildSetupFromModel(DependencyModel dependencyModel)
    {
        Setup setup = new Setup();
        setup.model = dependencyModel;
        setup.analyzer = new JreAnalyzer(dependencyModel);
        setup.verifier = new VerifierImplementation(dependencyModel);
        setup.metrics = new MetricsImplementation(dependencyModel);
        return setup;
    }

    /// <summary>
/// Analyze the given modules for dependencies and add them to the current
/// dependency model.
/// </summary>
/// <param name="projectModuleFiles"></param>
    public void startAnalysis(String[] projectModuleFiles)
    {
        analyzer.buildDependencies(projectModuleFiles);
    }

    /// <summary>
/// Analyze the given modules for dependencies and add them to the current
/// dependency model.
/// </summary>
/// <param name="projectModules"></param>
    public void startAnalysis(Package[] projectModules)
    {
        analyzer.buildDependencies(projectModules);
    }

    /// <summary>
/// XML reports will give you an overview on a certain aspect of your project. This can be for
/// example a complete analysis of code metrics or code duplicates.
/// </summary>
    public <TReport extends Report> void CreateReportXml(String reportFilePath, String  xslTransformReference)
    {
    }

    public DependencyModel getModel()
    {
        return model;
    }

    public Analyzer getAnalyzer()
    {
        return analyzer;
    }

    public Verifier getVerifier()
    {
        return verifier;
    }

    public Metrics getMetrics()
    {
        return metrics;
    }
}
